import React, { PureComponent } from 'react'
import { Form, Table } from 'antd'
import { connect } from 'dva'
import styles from './Index.less'
import columns from '../propList/columns'

// import { getValue } from '@/utils/utils'
@connect(({ loading, propExpired }) => ({
  propExpired,
  loading: loading.models.propExpired,
}))
@Form.create()
export default class List extends PureComponent {
  // 表格动作触发事件
  handleListChange = (pg, filtersArg, sorter) => {
    const { dispatch } = this.props
    const { formValues, pagination } = this.props.propExpired
    if (sorter.field && pagination.currentPage === pg.current) {
      return
    }

    const params = {
      ...formValues,
      current: pg.current,
      // size: pg.pageSize,
    }
    dispatch({
      type: 'propExpired/fetchList',
      payload: {
        ...params,
        // type: 3,
      },
    })
  }

  render() {
    const { loading } = this.props
    const { list, pagination } = this.props.propExpired

    return (
      <div className={styles.standardTable}>
        <Table
          loading={loading}
          size="small"
          bordered
          dataSource={list}
          rowKey={record => record.id}
          pagination={pagination}
          columns={columns}
          onChange={this.handleListChange}
          // scroll={{ x: 800 }}
        />
      </div>
    )
  }
}
